import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 定位信标信息 */
export interface DeviceBeacon {
  id: number // 编号
  imei?: string // 序列号
  macCode?: string // MAC地址
  majorCode?: string // 主标识
  minorCode?: string // 子标识
  schoolCode?: string // 所属园区
  classId: number // 班级ID
  locationName?: string // 信标位置
  sort?: number // 排序
  locationType?: string // 位置类型
  status?: number // 状态
}

// 定位信标 API
export const DeviceBeaconApi = {
  // 查询定位信标分页
  getDeviceBeaconPage: async (params: any) => {
    return await request.get({ url: `/school/device-beacon/page`, params })
  },

  // 查询定位信标详情
  getDeviceBeacon: async (id: number) => {
    return await request.get({ url: `/school/device-beacon/get?id=` + id })
  },

  // 新增定位信标
  createDeviceBeacon: async (data: DeviceBeacon) => {
    return await request.post({ url: `/school/device-beacon/create`, data })
  },

  // 修改定位信标
  updateDeviceBeacon: async (data: DeviceBeacon) => {
    return await request.put({ url: `/school/device-beacon/update`, data })
  },

  // 删除定位信标
  deleteDeviceBeacon: async (id: number) => {
    return await request.delete({ url: `/school/device-beacon/delete?id=` + id })
  },

  /** 批量删除定位信标 */
  deleteDeviceBeaconList: async (ids: number[]) => {
    return await request.delete({ url: `/school/device-beacon/delete-list?ids=${ids.join(',')}` })
  },

  // 导出定位信标 Excel
  exportDeviceBeacon: async (params) => {
    return await request.download({ url: `/school/device-beacon/export-excel`, params })
  }
}
